const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static',
  productionSourceMap: false,
  transpileDependencies: true,

  chainWebpack: config => {
    config.plugin('html').tap(args => {
      args[0].title = '后台管理系统'
      return args
    })
    config.plugin('define').tap(args => {
      const date = new Date()
      const y = date.getFullYear()
      const m = String(date.getMonth() + 1).padStart(2, '0')
      const d = String(date.getDate()).padStart(2, '0')
      const h = String(date.getHours()).padStart(2, '0')
      const i = String(date.getMinutes()).padStart(2, '0')
      args[0]['process.env'].version = JSON.stringify(`${y}${m}${d}${h}${i}`)
      return args
    })
  },
  devServer: {
    hot: true,
    open: true,
    client:{
      overlay:false
    },
    historyApiFallback:{
      index:'/index.html'
    },
    proxy: {
      '/api': {
        //target: 'http://192.168.1.161:21818',
        target: 'https://zyykjcgzhxt.cdutcm.edu.cn/api',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      },
    }
  },
})
